package com.vftour.stu.mq.rabbitmq.handler;

import com.vftour.stu.mq.rabbitmq.constant.RabbitConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * TopicQueueHandler
 *
 * @version 1.0
 * @author: 东东 | d@tke.store
 * @date :  2022/3/5 6:02 下午
 */
@Slf4j
@Component
public class TopicQueueHandler {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "topic.queue.1"),
            exchange = @Exchange(name = RabbitConstant.TOPIC_MODE_QUEUE,type = ExchangeTypes.TOPIC),
            key = {"china.#"}
    ))
    public void directOneHandler(String message) {
        System.out.println("one-----" + message);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "topic.queue.2"),
            exchange = @Exchange(name = RabbitConstant.TOPIC_MODE_QUEUE,type = ExchangeTypes.TOPIC),
            key = {"#.news"}
    ))
    public void directTwoHandler(String message) {
        System.out.println("two-----" + message);
    }
}
